package OneDayMoreThread;


public class Thread7 implements Runnable{
    private int prime;
    private int q;
    private int w;
    public Thread7(int nn,int mm){
        this.q=nn;
        this.w=mm;
    }
    @Override
    public void run() {
        isPrime(q,w);//判断素数
    }
    public void isPrime(int min,int max) {
        int k=max;
        int s=min;
        if (max<min){
            System.out.println("最大数不能小于最小数，请重新输入");
            return;
        }else if (max<=0||min<=0){
            System.out.println("输入的数据不能为负数");
            return;
        }
        for (int i=k;i>s;i--){
            if (i==1){//1不是素数
                continue;
            }
            prime=i%2;//去掉偶数
            if (prime==0&&i>3){
                continue;
            }
            prime=i%3;//去掉整除3的数
            if (prime==0&&i>7){
                continue;
            }
            prime=i%5;//去掉整除5的数
            if (prime==0&&i>7){
                continue;
            }
            prime=i%7;//去掉整除7的数
            if (prime==0&&i>7){
                continue;
            }
            System.out.println(Thread.currentThread().getName()+"素数 = " + i);
        }
    }

    public static void main(String[] args) {
        Thread thread1 = new Thread(new Thread7(3, 20));
        thread1.start();
        Thread thread2 = new Thread(new Thread7(3, 15));
        thread2.start();
        Thread thread3 = new Thread(new Thread7(2, 60));
        thread3.start();
    }
}
